﻿@{
    var currentTime = DateTime.Now;
}
<div class="search">
    <div class="right">
        <label>@currentTime.ToString(string.Format("yyyy{0}MM{1}dd{2}", "年".Label(), "月".Label(), "日".Label()))</label>
        &nbsp;
        <input type="radio" name="form_mealtime" id="form_lunch" value="1" @if (currentTime.Hour <= 12)
                                                                           {<text>checked="checked"</text>}  />@("午餐".Label())&nbsp;
        <input type="radio" name="form_mealtime" id="form_supper" value="2"@if (currentTime.Hour > 12)
                                                                           {<text>checked="checked"</text>} />@("晚餐".Label())&nbsp;
    </div>
    @if (Kooboo.CMS.FoodOrdering.Areas.Customer.Models.LoginModel.Current.IsAuthenticated)
    {
        var orderDetailQuery = ContentHelper.TextFolder(Kooboo.CMS.FoodOrdering.Areas.FoodOrdering.FoodOrderingAreaRegistration.OrderDetailFolderName).CreateQuery();
        string ordertime = currentTime.ToString("yyyyMMdd");
        var username = Kooboo.CMS.FoodOrdering.Areas.Customer.Models.LoginModel.Current.Username;
        var orderLunch = orderDetailQuery.WhereEquals("User", username).WhereEquals("OrderTime", ordertime).WhereEquals("Meal", "1").FirstOrDefault();
        var orderSupper = orderDetailQuery.WhereEquals("User", username).WhereEquals("OrderTime", ordertime).WhereEquals("Meal", "2").FirstOrDefault();

        if (orderLunch != null)
        {   
        <div id="dvUserPanelLunch" class="dvUserPanel" style="display: block;">
            <b>@("Lunch".Label())：</b><span> [@orderLunch["Restaurant"]] @orderLunch["Food"]
                ￥@orderLunch["Price"].ToString()</span><a title="delete" class="delete" meal="1">@orderLunch["UUID"].ToString()</a>
        </div>     
        }
        else
        {
        <div id="dvUserPanelLunch" class="dvUserPanel" style="display: none;">
            <b>@("Lunch".Label())：</b><span></span><a title="delete" class="delete" meal="1"></a>
        </div>
        }
        if (orderSupper != null)
        { 
        <div id="dvUserPanelSupper" class="dvUserPanel" style="display: block;">
            <b>@("Supper".Label())：</b><span> [@orderSupper["Restaurant"]] @orderSupper["Food"]
                ￥@orderSupper["Price"].ToString()</span><a title="delete" class="delete" meal="2">@orderSupper["UUID"].ToString()</a>
        </div>
        }
        else
        {
        <div id="dvUserPanelSupper" class="dvUserPanel" style="display: none;">
            <b>@("Supper".Label())：</b><span></span><a title="delete" class="delete" meal="2"></a>
        </div>
        }
    }
</div>
